package com.west.imserver.parser;

import imserverentity.entity.IChattable;
import imserverentity.entity.Protocol;

import java.io.ObjectOutputStream;
import java.net.Socket;

import com.west.imserver.handler.IHandler;
import com.west.imserver.handler.impl.ChatHandler;
import com.west.imserver.handler.impl.LoginHandler;
import com.west.imserver.handler.impl.LogoutHandler;
import com.west.imserver.handler.impl.ShakeHandler;

public class Parser {
	public static IHandler parse(Protocol protocol, ObjectOutputStream oos) {
		String msgType = protocol.getMsgType();
		switch (msgType) {
		case "login":
			return new LoginHandler("syn", protocol.getParams(), oos);
		case "logout":
			return new LogoutHandler("syn", protocol.getParams());
		case "chat":
			return new ChatHandler("chat", protocol.getParams(), oos);
		case "shake":
			return new ShakeHandler("shake", protocol.getParams(), oos);
		default:
			return null;
		}
	}
}
